package org.zhxy.core.principal.controller;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.zhxy.common.aop.AutomaticLog;
import org.zhxy.common.config.ServiceFactory;
import org.zhxy.common.response.Result;
import org.zhxy.common.response.ResultCode;

import java.sql.ResultSet;
import java.util.Map;

@RestController
@RequestMapping("/school")
public class SchoolController {

    @RequestMapping(value = "/getSchoolList",method = RequestMethod.GET)
    public Result getSchoolList(){
        return new Result(ResultCode.SUCCESS_NO_MESSAGE, ServiceFactory.schoolService.getSchoolList());
    }

    @AutomaticLog("添加集团/校区/部门")
    @RequestMapping(value = "/saveSchoolOrSubSchoolOrDepartment",method = RequestMethod.POST)
    public Result saveSchoolOrSubSchoolOrDepartment(@RequestBody Map<String, Object> map) throws Exception {
        return ServiceFactory.schoolService.saveSchoolOrSubSchoolOrDepartment(map);
    }

    @AutomaticLog("修改集团/校区/部门")
    @RequestMapping(value = "/updateSchoolOrSubSchoolOrDepartment",method = RequestMethod.POST)
    public Result updateSchoolOrSubSchoolOrDepartment(@RequestBody Map<String, Object> map) throws Exception {
        return ServiceFactory.schoolService.updateSchoolOrSubSchoolOrDepartment(map);
    }

    @AutomaticLog("删除集团/校区/部门")
    @RequestMapping(value = "/removeSchoolOrSubSchoolOrDepartment",method = RequestMethod.POST)
    public Result removeSchoolOrSubSchoolOrDepartment(@RequestBody Map<String, Object> map){
        return ServiceFactory.schoolService.removeSchoolOrSubSchoolOrDepartment(map);
    }

    //@AutomaticLog("级联获得部门集合")
    @RequestMapping(value = "/searchDepartmentBySchool",method = RequestMethod.GET)
    public Result searchDepartmentBySchool(){
        return ServiceFactory.schoolService.searchDepartmentBySchool();
    }

    @AutomaticLog("级联查询专业")
    @RequestMapping(value = "/searchCasVocationalList",method = RequestMethod.GET)
    public Result searchCasVocationalList(){
        return Result.SUCCESS_NO_MESSAGE(ServiceFactory.schoolService.searchCasVocationalList());
    }

    @AutomaticLog("级联查询班级")
    @RequestMapping(value = "/searchCasClassesList",method = RequestMethod.GET)
    public Result searchCasClassesList(){
        return Result.SUCCESS_NO_MESSAGE(ServiceFactory.schoolService.searchCasClassesList());
    }

}
